package org.atlantis.grosbeak.pot.dao;

import java.util.List;

import org.atlantis.grosbeak.pot.elm.Arg;
import org.atlantis.grosbeak.pot.elm.MappedBy;
import org.atlantis.grosbeak.pot.elm.Query;
import org.atlantis.grosbeak.pot.elm.Unique;
import org.atlantis.grosbeak.pot.elm.Update;

public interface UserDao {

	@Unique
	@MappedBy(UserEntityRowMapper.class)
	@Query("SELECT * FROM USERS u WHERE u.USER_ID = :id")
	UserEntity queryById(@Arg("id") int id);

	@MappedBy(UserEntityRowMapper.class)
	@Query("SELECT * FROM USERS u ORDER BY u.USER_ID")
	List<UserEntity> queryAll();

	@Update("INSERT INTO USERS(USER_NAME, USER_GENDER, USER_AGE) values(:u.name, :u.gender, :u.age)")
	void save(@Arg("u") UserEntity userEntity);

	@Update("UPDATE USERS SET USER_NAME = :name WHERE USER_ID = :id")
	void update(@Arg("name") String name, @Arg("id") int id);
	
	@Update("DELETE FROM USERS WHERE USER_ID = :id")
	void delete(@Arg("id") int id);
}
